package com.bjsxt;

import java.util.ArrayList;
import java.util.List;
import java.util.function.Consumer;
//实现Consumer接口实现类
class Com implements Consumer{

    @Override
    public void accept(Object o) {
        System.out.println(o);
    }
}
public class ListLambda {
    public static void main(String[] args) {
        List<String> list = new ArrayList<>();
        list.add("a");
        list.add("b");
        list.add("c");
        list.add("d");


        //定义抽象类
        Com c = new Com();
        list.forEach(c);

        System.out.println("-----直接用Lambda表达遍历-------");
        list.forEach(System.out::println);
    }
}
